home *** CD-ROM | disk | FTP | other *** search
/ Sky at Night 2007 June / SAN CD 6-2007 CD-ROM 25.iso / pc / Software / AstroGrav_Win / Java / jre1.6.0 / lib / rt.jar / javax / smartcardio / ATR.class (.txt) next >
Encoding:
Java Class File  |  2006-11-29  |  1.5 KB  |  94 lines

  1. package javax.smartcardio;
  2.  
  3. import java.io.IOException;
  4. import java.io.ObjectInputStream;
  5. import java.io.Serializable;
  6. import java.util.Arrays;
  7.  
  8. public final class ATR implements Serializable {
  9.    private static final long serialVersionUID = 6695383790847736493L;
  10.    private byte[] atr;
  11.    private transient int startHistorical;
  12.    private transient int nHistorical;
  13.  
  14.    public ATR(byte[] var1) {
  15.       this.atr = (byte[])(([B)var1).clone();
  16.       this.parse();
  17.    }
  18.  
  19.    private void parse() {
  20.       if (this.atr.length >= 2) {
  21.          if (this.atr[0] == 59 || this.atr[0] == 63) {
  22.             int var1 = (this.atr[1] & 240) >> 4;
  23.             int var2 = this.atr[1] & 15;
  24.             int var3 = 2;
  25.  
  26.             while(var1 != 0 && var3 < this.atr.length) {
  27.                if ((var1 & 1) != 0) {
  28.                   ++var3;
  29.                }
  30.  
  31.                if ((var1 & 2) != 0) {
  32.                   ++var3;
  33.                }
  34.  
  35.                if ((var1 & 4) != 0) {
  36.                   ++var3;
  37.                }
  38.  
  39.                if ((var1 & 8) != 0) {
  40.                   if (var3 >= this.atr.length) {
  41.                      return;
  42.                   }
  43.  
  44.                   var1 = (this.atr[var3++] & 240) >> 4;
  45.                } else {
  46.                   var1 = 0;
  47.                }
  48.             }
  49.  
  50.             int var4 = var3 + var2;
  51.             if (var4 == this.atr.length || var4 == this.atr.length - 1) {
  52.                this.startHistorical = var3;
  53.                this.nHistorical = var2;
  54.             }
  55.  
  56.          }
  57.       }
  58.    }
  59.  
  60.    public byte[] getBytes() {
  61.       return (byte[])this.atr.clone();
  62.    }
  63.  
  64.    public byte[] getHistoricalBytes() {
  65.       byte[] var1 = new byte[this.nHistorical];
  66.       System.arraycopy(this.atr, this.startHistorical, var1, 0, this.nHistorical);
  67.       return var1;
  68.    }
  69.  
  70.    public String toString() {
  71.       return "ATR: " + this.atr.length + " bytes";
  72.    }
  73.  
  74.    public boolean equals(Object var1) {
  75.       if (this == var1) {
  76.          return true;
  77.       } else if (!(var1 instanceof ATR)) {
  78.          return false;
  79.       } else {
  80.          ATR var2 = (ATR)var1;
  81.          return Arrays.equals(this.atr, var2.atr);
  82.       }
  83.    }
  84.  
  85.    public int hashCode() {
  86.       return Arrays.hashCode(this.atr);
  87.    }
  88.  
  89.    private void readObject(ObjectInputStream var1) throws IOException, ClassNotFoundException {
  90.       this.atr = (byte[])var1.readUnshared();
  91.       this.parse();
  92.    }
  93. }
  94.